<?
/*
-------------------------------
Script - EvaGb
-------------------------------
File - install.php
-------------------------------
Function - Импорт БД
-------------------------------
*/
if (file_exists("db.sql")) {
    if ($_POST['done']) {
        extract($_POST);
        $l= mysql_connect($db_host,$db_user,$db_pass) or die(mysql_error());
        mysql_select_db($db_name,$l);
        $fp=file_get_contents("db.sql");
        $fp=str_replace("{prf}",$perf,$fp);
        $fp=explode(';',$fp);
        for($i=0,$c=count($fp);$i<$c;$i++) {
           $fp[$i]=trim($fp[$i]);
           if (!empty($fp[$i])) mysql_query($fp[$i]) or die(mysql_error());
        }
        print "Установка завершена <br>";
        unlink("db.sql");
        die();
    }
    print "
    <form method=POST>
         <table width=50% align=center border=1>
         <tr>
         <td>Префикс</td><td><input type=text name='perf' value='evagb'></td>
         <tr>
         <td>Пароль БД</td><td><input type=text name='db_pass' ></td>
         <tr>
         <td>Имя БД</td><td><input type=text name='db_name' ></td>
         <tr>
         <td>Пользователь</td><td><input type=text name='db_user'></td>
         <tr>
         <td>Хост</td><td><input type=text name='db_host'></td>
         <tr>
         <td colspan=2><input type=submit value='Установить' name='done'></td>
         </table>
    <form>
    ";
}
?>
